﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Snowdreamist.Windows.Navigation.Primitives
{
    public class SessionManager
    {
        public IEnumerable<Session> Sessions
        {
            get
            {
                return this._sessions.ToArray();
            }
        }

        internal void AddSession(Session session)
        {
            if (session == null)
                throw new ArgumentNullException("session");

            lock (this)
            {
                if (this._sessions.Contains(session))
                    throw new ValueExistsException("Session is already existed");
                this._sessions.Add(session);
            }
        }

        internal void RemoveSession(Session session)
        {
            if (session == null)
                throw new ArgumentNullException("session");

            lock (this)
            {
                this._sessions.Remove(session);
            }
        }

        #region private

        private readonly List<Session> _sessions = new List<Session>();

        #endregion private
    }
}